1 package org.smartcomps.twister.engine.core.dynamic; 2 3 import junit.framework.TestCase; 4 import org.smartcomps.twister.engine.priv.core.dynamic.ExecutionContextFactory; 5 import org.smartcomps.twister.engine.priv.core.dynamic.ProcessInstanceFactory; 6 import org.smartcomps.twister.engine.priv.core.dynamic.ProcessInstance; 7 import org.smartcomps.twister.engine.priv.core.dynamic.EmptyEC; 8 import org.smartcomps.twister.engine.priv.core.dynamic.ExecutionContext; 9 import org.smartcomps.twister.engine.core.definition.TestEmpty; 10 import org.smartcomps.twister.engine.core.definition.TestProcess; 11 import org.smartcomps.twister.common.transaction.TransactionManager; 12 import org.smartcomps.twister.common.lifecycle.LifecycleManager; 13 import net.sf.hibernate.tool.hbm2ddl.SchemaExport; 14 import net.sf.hibernate.cfg.Configuration; 15 16 import java.util.Map; 17 import java.util.HashMap; 18 19 public class TestEmptyEC extends TestCase { 20 21 public EmptyEC testEmptyEC = null; 22 23 private TestEmpty testEmpty = new TestEmpty(); 24 private TestProcess testProcess = new TestProcess(); 25 26 protected void setUp() throws Exception { 27 LifecycleManager.getLifecycleManager().createResources(); 28 LifecycleManager.getLifecycleManager().startResources(); 29 30 SchemaExport schemaExport = new SchemaExport(new Configuration().configure()); 31 schemaExport.create(true, true); 32 33 TransactionManager.beginTransaction(); 34 testProcess.testCreateWithCorrelation(); 35 // Empty is using the process created in TestProcess 36 testEmpty.testCreate(); 37 } 38 39 protected void tearDown() throws Exception { 40 TransactionManager.commitTransaction(); 41 42 LifecycleManager.getLifecycleManager().stopResources(); 43 LifecycleManager.getLifecycleManager().destroyResources(); 44 } 45 46 public void testCreate() throws Exception { 47 Map corrProp = new HashMap(); 48 corrProp.put(TestProcess.CORRELATION_PROP1, "2578"); 49 corrProp.put(TestProcess.CORRELATION_PROP2, "12"); 50 ProcessInstance pi = ProcessInstanceFactory.createProcessInstance(TestEmpty.empty.getProcess(), 51 TestProcess.CORRELATION_NAME, corrProp); 52 EmptyEC emptyEC = (EmptyEC) ExecutionContextFactory.createExecutionContext(TestEmpty.empty, pi); 53 54 TransactionManager.commitTransaction(); 55 TransactionManager.beginTransaction(); 56 57 ProcessInstance createdInstance = ProcessInstanceFactory.findInstanceByCorrelation(TestProcess.CORRELATION_NAME, corrProp); 58 assertTrue("Instance child ec is not a EmptyEC", 59 createdInstance.getChildExecutionContext() instanceof EmptyEC); 60 testEmptyEC = (EmptyEC) createdInstance.getChildExecutionContext(); 61 } 62 63 public void testExecute() throws Exception { 64 Map corrProp = new HashMap(); 65 corrProp.put(TestProcess.CORRELATION_PROP1, "2578"); 66 corrProp.put(TestProcess.CORRELATION_PROP2, "12"); 67 68 TestEmpty.empty.execute(TestProcess.CORRELATION_NAME, corrProp); 69 70 TransactionManager.commitTransaction(); 71 TransactionManager.beginTransaction(); 72 73 ProcessInstance createdInstance = ProcessInstanceFactory.findInstanceByCorrelation(TestProcess.CORRELATION_NAME, corrProp); 74 assertEquals("Process is not completed after execution ended", ProcessInstance.COMPLETED, createdInstance.getStatus()); 75 assertEquals("Empty is not completed after execution ended", ExecutionContext.COMPLETED, createdInstance.getChildExecutionContext().getStatus()); 76 } 77 }

This page was automatically generated by Maven